package day03;

import java.sql.SQLOutput;
import java.util.Scanner;

public class ExpandHomeWork {
    public static void main(String[] args) {
        // 1.声明两个整型变量a和b并分别赋值，找到a和b中的最大值，并输出。用两种方式实现：条件运算符、if..else分支结构。
        int num1 = 8, num2 = 14;
        int max = num1>num2? num1:num2;
        System.out.println("max="+max);

        if(num1>num2){
            System.out.println("max="+num1);
        }else{
            System.out.println("max="+num2);
        }

        //2. 声明一个整型变量year并存储年份，判断其是平年还是闰年，若是闰年则输出"某某某年是闰年"，否则输出"某某某年是平年"。
        int year = 2005;
        if(year%4==0 && year%100!=0 || year%400==0){
            System.out.println(year+"年是闰年");
        }else{
            System.out.println(year+"年是平年");
        }

        /*
        3. 成绩等级判断：
        A:成绩大于等于90
        B:成绩大于等于80并且小于90
        C:成绩大于等于60并且小于80
        D:成绩小于60
        */

        int score = 84;
        if(score<0 || score>100){
            System.out.println("成绩不合法");
        } else if (score>=90){
            System.out.println("成绩为："+score+"，等级为：A");
        }else if(score>=80){
            System.out.println("成绩为："+score+"，等级为：B");
        }else if(score>=60){
            System.out.println("成绩为："+score+"，等级为：C");
        }else {
            System.out.println("成绩为："+score+"，等级为：D");
        }

        //4.接收用户输入的年份year和月份month，计算该年该月的天数，并输出
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入年份：");
        int years = scan.nextInt();
        System.out.println("请输入月份：");
        int month = scan.nextInt();
        int days = 0;
        switch (month){
            case 1:
                days = 31;
                break;
            case 2:
                if(years%4==0 && year%100!=0 || year%400==0){
                    days = 29;
                }else{
                    days = 28;
                }
                break;
            case 3:
                days = 31;
                break;
            case 4:
                days = 30;
                break;
            case 5:
                days = 31;
                break;
            case 6:
                days = 30;
                break;
            case 7:
                days = 31;
                break;
            case 8:
                days = 31;
                break;
            case 9:
                days = 30;
                break;
            case 10:
                days = 31;
                break;
            case 11:
                days = 30;
                break;
            case 12:
                days = 31;
                break;
        }
        System.out.println(years+"年的"+month+"月共"+days+"天");

        //求1加到100的和
        int i, sum = 0;
        for(i=1;i<=100;i++){
            sum +=i;
        }
        System.out.println(sum);
    }
}
